﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using MongoDB.Driver;

namespace Inovout.Cloud.DataStore.Services
{
    /// <summary>
    /// MongoDB服务器
    /// </summary>
    public interface IMongoServerService
    {
        //Mongo DB 服务器连接字符串
        public virtual string connectionString;

        public virtual MongoServer mongoServer;
        
        /// <summary>
        /// 连接Mongo DB 服务器
        /// </summary>
        void Connect();

        /// <summary>
        /// 连接Mongo DB 服务器
        /// </summary>
        /// <param name="timeSpan">指定连接超时时间</param>
        void Connect(TimeSpan timeSpan);

        /// <summary>
        /// 连接Mongo DB 服务器
        /// </summary>
        void ReConnect();

        /// <summary>
        /// 断开与Mongo DB服务器之间的连接
        /// </summary>
        void Disconnect();

        /// <summary>
        /// 关闭MongoDB服务器
        /// </summary>
        void Shutdown();

        /// <summary>
        /// 根据数据库名取得某一个数据库对象
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        /// <returns></returns>
        MongoDatabase GetDatabase(string databaseName);

        /// <summary>
        /// 取得Mongo DB Server上的所有数据库名
        /// </summary>
        /// <returns></returns>
        IEnumerable<string> GetDatabaseNames();

        /// <summary>
        /// 取得Mongo DB Server上的所有数据库
        /// </summary>
        /// <returns></returns>
        IEnumerable<MongoDatabase> GetDatabases();

        /// <summary>
        /// 判断数据库是否存在
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        /// <returns></returns>
        bool DatabaseExists(string databaseName);

        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        /// <returns></returns>
        bool DropDatabase(string databaseName);

    }
}
